package com.jinke.api.modules.third.dqpost.model.response;

import com.jinke.api.common.api.CommonResult;
import lombok.Data;

import java.math.BigDecimal;

@Data
public class GetPriceResponse {
    private Integer code;

    private String msg;
    private GetPriceResponseDetail data;
    private Boolean success = true;

    @Data
    public static class GetPriceResponseDetail {
        private String service;
        private String time;
        private String currency;
        private BigDecimal price;
    }

    public CommonResult toCommonResult() {
        // 判断是否成功
        CommonResult commonResult = CommonResult.success();
        if (!isSuccess()) {
            commonResult = CommonResult.failed(msg);
            success = false;
        }
        return commonResult;
    }

    public boolean isSuccess() {
        boolean result = true;
        // 判断是否成功
        if (code != 200) {
            result = false;
        }
        return result;
    }

}
